package com.xhh.user.controller.v1;

import com.xhh.model.common.dtos.ResponseResult;
import com.xhh.model.common.enums.AppHttpCodeEnum;
import com.xhh.model.user.vos.PermissionListVo;
import com.xhh.user.service.IPermissionService;
import lombok.RequiredArgsConstructor;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.util.StringUtils;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;


@RestController
@RequestMapping("/user/permission")
@RequiredArgsConstructor
public class PermissionController {

    private final IPermissionService iPermissionService;

    /**
     * 根据用户id获取所属的权限
     * @param userId
     * @return
     */
    @GetMapping("getPermissionByUserId")
    public ResponseResult getPermissionByUserId(Long userId){
        if(StringUtils.isEmpty(userId)){
            return ResponseResult.errorResult(AppHttpCodeEnum.PARAM_INVALID, "用户id不能为空!");
        }
        /*List<PermissionListVo> permissionListVos = iPermissionService.getPermissionByUserId(userId);
        return ResponseResult.okResult(permissionListVos);*/
        return iPermissionService.getPermissionByUserId(userId);
    }


}
